const initState = () => {
    return {
        emailVerifyData: {
            isShow: false,
            cardTransition: "",
            title: "Email verification",
            desc: "An email with verification code has been sent to",
            desc2: "Please enter your verification code below to proceed.",
            email: "xxxxxxx@gmail.com",
            realEmail: "",
            password: "",
            btn: "Verify",
            verify: {
                title: "",
                placeholder: "Verification Code",
                tip: "Please enter a verification Code.",
                asyncTip: "Invalid Code",
                value: "",
                name: "password",
            },
        }
    };
};

const state = initState();

const mutations = {
    //保护邮箱
    protectEmail(state) {
        let currentEmail = state.emailVerifyData.realEmail.split('@');
        let tempArr = [];
        for (let i in currentEmail[0]) {
            tempArr.push('x')
        }
        state.emailVerifyData.email = tempArr.join('') + "@" + currentEmail[1]
    },
    //打开邮箱验证弹窗
    openEmailVerifyPop(state, type) {
        state.emailVerifyData.cardTransition = type ? type : 'contentLeaveRotate';
        state.emailVerifyData.isShow = true;
    },
    //关闭邮箱验证弹窗
    closeEmailVerifyPop(state, type) {
        state.emailVerifyData.cardTransition = type ? type : 'contentEnterRotate';
        state.emailVerifyData.isShow = false;
        setTimeout(() => {
            this.commit('emailVerify/resetState');
        });
    },
    resetState(state) {
        Object.assign(state, initState());
    }
};

const actions = {};

const getters = {};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
};